#ifndef CONVEYOR_H
#define CONVEYOR_H

#include <BMPackSim_global.h>

#include <gui\graphicsview\qgraphicsitem.h>
#include <corelib\kernel\qobject.h>




namespace PackSim
{

	class EllipseItem;

	class PICKBUSINESS_EXPORT Conveyor : public QObject, public QGraphicsRectItem /*, public IConveyor*/
	{
		Q_OBJECT

		enum ConveyorState
		{
			eCsStopped,
			eCsStarted
		};


	public:

		Conveyor(QGraphicsItem* parent = 0);

		~Conveyor();


		void updateCnv(float aDeltaTime);
		void startCnv();
		void stopCnv();

		float velocity() const ;
		void setVelocity(float val);

		float acceleration() const;
		void setAcceleration(float val) ;

		void setColor(QColor& color);
		QColor color() const;

		void setRotation ( double angle );
		double rotation () const;

		void setPos ( double x, double y);
		void setPos ( const QPointF & pos );
		QPointF pos () const;

		void setRect ( const QRectF & rectangle );
		void setRect ( double x, double y, double width, double height );
		QRectF rect () const ;

		void appendNextConveyor(Conveyor* aConveyor);
		void removeNextConveyor(Conveyor* aConveyor);

		void appendPreviousConveyor(Conveyor* aConveyor);
		void removePreviousConveyor(Conveyor* aConveyor);

		QList<Conveyor*> nextConveyorList() const ;
		QList<Conveyor*> previousConveyorList() const ;



		inline PackSim::Conveyor::ConveyorState getConveyorState() const { return mConveyorState; }
		inline void setConveyorState(PackSim::Conveyor::ConveyorState val) { mConveyorState = val; }

		inline float getActualVelocity() const { return mActualVelocity; }
		inline void setActualVelocity(float val) { mActualVelocity = val; }


	signals:

		void ConveyorSignalItemEndOfCnv(Conveyor* conveyor, EllipseItem* item);
	

		

	private:

		void updateCnvItems(float aDeltaTime);
			
		QList<Conveyor*> mNextConveyorList;		
		QList<Conveyor*> mPreviousConveyorList;
		QColor mColor;


		// Conveyor Physics Related /////////		
		ConveyorState mConveyorState;
		float mVelocity;
		float mAcceleration;
		float mActualVelocity;
		
		/////////////////////////////////////
		
		


	};

}
#endif // CONVEYOR_H
